---
title: RSS Feed
description: Generate a RSS feed for your docs/blog.
---

## Setup

You can create the feed object:

```ts title="lib/rss.ts"
import { Feed } from 'feed';
import { source } from '@/lib/source';

const baseUrl = 'https://fumadocs.dev';

export function getRSS() {
  const feed = new Feed({
    title: 'Fumadocs Blog',
    id: `${baseUrl}/blog`,
    link: `${baseUrl}/blog`,
    language: 'en',

    image: `${baseUrl}/banner.png`,
    favicon: `${baseUrl}/icon.png`,
    copyright: 'All rights reserved 2025, Fuma Nama',
  });

  for (const page of source.getPages()) {
    feed.addItem({
      id: page.url,
      title: page.data.title,
      description: page.data.description,
      link: `${baseUrl}${page.url}`,
      date: new Date(page.data.lastModified),

      author: [
        {
          name: 'Fuma',
        },
      ],
    });
  }

  return feed.rss2();
}
```

And expose it using a server loader/route handler like:

```ts tab="Next.js" title="app/rss.xml/route.ts"
import { getRSS } from '@/lib/rss';

export const revalidate = false;

export function GET() {
  return new Response(getRSS());
}
```

```ts tab="React Router"
// app/routes/rss.ts
import { getRSS } from '@/lib/rss';

export async function loader() {
  return new Response(getRSS());
}

// app/routes.ts
import { route, type RouteConfig } from '@react-router/dev/routes';

export default [
  // ...
  route('rss.xml', 'routes/rss.ts'),
] satisfies RouteConfig;
```

```ts tab="Tanstack Start" title="src/routes/rss[.]xml.ts"
import { createFileRoute } from '@tanstack/react-router';
import { getRSS } from '@/lib/rss';

export const Route = createFileRoute('/rss.xml')({
  server: {
    handlers: {
      GET: async () => new Response(getRSS()),
    },
  },
});
```

### Next.js Metadata

You can add an alternates object to the metadata object with your feed’s title and URL.

```ts title="app/layout.tsx"
import type { Metadata } from 'next';

export const metadata: Metadata = {
  alternates: {
    types: {
      'application/rss+xml': [
        {
          title: 'Fumadocs Blog',
          url: 'https://fumadocs.dev/blog/index.xml',
        },
      ],
    },
  },
};
```
